#!/bin/sh
################################################################################
# telnet
################################################################################
. /etc/rc.d/functions

start() {
    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/updates] Starting..."

    if [ ! "x${MM_NOTIFY_ABOUT_UPDATES}" = "xno" ] ; then
        if [ -z `/bin/pidof mm_notify_updates` ] ; then
            /usr/bin/mm_notify_updates ${MM_NOTIFY_ABOUT_UPDATES} &
            /usr/bin/logger -t minimyth -p "local0.info" "[init.d/updates] Starting NOTIFY_UPDATES daemon. Check period is ${MM_NOTIFY_ABOUT_UPDATES} min..."
        fi
    fi

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/updates] Started with return code=0..."

    return 0
}

stop() {

    if [ ! "x${MM_NOTIFY_ABOUT_UPDATES}" = "xno" ] ; then
        if [ -n "`/bin/pidof mm_notify_updates`" ] ; then
            /usr/bin/logger -t minimyth -p "local0.info" "[init.d/updates] Killing NOTIFY_UPDATES daemon..."
            /usr/bin/killall -9 mm_notify_updates > /dev/null 2>&1
        fi
    fi

    return 0
}

case $1 in
    start) start ;;
    stop)  stop  ;;
esac

exit 0
